#include "tracker_display_model.h"

tracker_display_model::tracker_display_model(QList < QVector<int> >& datasource,QObject *parent) :
    QAbstractTableModel(parent)
{
     m_datasource=datasource;
     cols=datasource.size();
     rows=24;
}


//-----------------------------------------------------------------
int tracker_display_model::rowCount(const QModelIndex & /*parent*/) const
{
    return rows;
}

//-----------------------------------------------------------------
int tracker_display_model::columnCount(const QModelIndex & /*parent*/) const
{
    return cols;
}

void tracker_display_model::setdatasource( QList < QVector<int> >& datasource)
{
    m_datasource=datasource;


}

//-----------------------------------------------------------------
QVariant tracker_display_model::data(const QModelIndex &index, int role) const
{
    if (role == Qt::DisplayRole )
    {
        if(datasource[index.column()])    return 0;
        else return 1;

    }

    else return QVariant();
}



bool tracker_display_model::setData(const QModelIndex & index, const QVariant & value, int role)
{
    if (role == Qt::EditRole)
    {
//       if(index.column()==1)
//       datamap[ keylist[index.row()]] = value.toInt();

      //  emit editCompleted( result );
    }
    return true;
}


Qt::ItemFlags tracker_display_model::flags(const QModelIndex & /*index*/) const
{
    return Qt::ItemIsSelectable |  Qt::ItemIsEditable | Qt::ItemIsEnabled ;
}

